<template>
    <view class="download-page">
        <scroll-view class="w-screen download-content" scroll-y>
            <view class="w-full flex flex-col">
                <view
                    class="py-4 flex items-center b-b-solid b-3 b-gray"
                    v-for="item of downloadInfoList"
                    :key="item.content"
                >
                    <view class="flex justify-center w-full px-6 text-4 text-gray">
                        <text selectable="true" user-select="true" v-if="item.type == 'text'">{{ item.content }}</text>
                        <image
                            mode="heightFix"
                            show-menu-by-longpress="true"
                            draggable="true"
                            v-else-if="item.type == 'img'"
                            :src="baseURL + item.content"
                        ></image>
                        <text v-else>不支持的类型，type：{{ item.type }}</text>
                    </view>
                </view>
            </view>

            <view>
                <official-account style=""></official-account>
            </view>
        </scroll-view>
        <CustomTabBar />
    </view>
</template>

<script setup lang="ts">
    import { DownloadInfo, baseURL, getDownloadInfo } from "@/api/api"
    import { ref } from "vue"
    import CustomTabBar from "@/components/CustomTabBar.vue"
    import { onShow } from "@dcloudio/uni-app"

    // 隐藏导航栏左侧返回按钮
    onShow(() => {
        // @ts-ignore
        if (typeof wx !== 'undefined' && wx.hideHomeButton) {
            // @ts-ignore
            wx.hideHomeButton();
        }
    });
    
    const downloadInfoList = ref([] as DownloadInfo[])

    getDownloadInfo().then((r) => (downloadInfoList.value = r))

    uni.showShareMenu();
</script>

<style scoped>
.download-page {
    position: relative;
    height: 100vh;
}

.download-content {
    padding-bottom: 50px;
    height: 100%;
}
</style>
